<?php
class UserModule extends Module {
	public function index() {
		$this->login();
	}
	
	public function login() {
		$a = Auth::getAuth();
		if ($a->loggedIn()) {
			redirect(WEB_ROOT);
		}
		$this->render('login');
	}
	
	public function confirm() {
		$Auth = Auth::getAuth();
		$user = $_POST['username'];
		$pw = $_POST['password'];
		if ($Auth->login($user,$pw)) {
			redirect(WEB_ROOT);
		} else {
			$this->set('login_error', 1);
		}
		$this->login();
	}
	
	public function logout() {
		$Auth = Auth::getAuth();
		$Auth->logout();
		$this->render('login');
	}
}
